import http from '../utils/request'

export const getMenu = (data) => {
    // 返回一个promise对象
    return http.post('/login', data)
}
export const getMenuList = (data) => {
    return http.get('/menus', data)  //左侧菜单
}
export const getUserList = (params) => {
    return http.get('/users', params)  //用户列表
}
export const getUserState = (uid, type) => {
    return http.put(`/users/${uid}/state/${type}`)  //状态
}
export const addUser = (data) => {
    return http.post('/users', data)  //添加用户
}
export const getUserId = (id) => {
    return http.get(`/users/${id}`)  //根据id查询用户信息 编辑
}
export const editUser = (id,data) => {
    return http.put(`/users/${id}`, data)  //编辑提交用户
}
export const deleteUser = (id) => {
    return http.delete(`/users/${id}`)  //删除用户
}
export const rightsList = () => {
    return http.get('/rights/list')  //权限列表
}
export const rolesList = () => {
    return http.get('/roles')  //角色列表
}
export const addRole = (data) => {
    return http.post('/roles',data)  //添加角色
}
export const getRoleId = (id) => {
    return http.get(`/roles/${id}`)  //根据id查询角色信息 编辑
}
export const editRole = (id,data) => {
    return http.put(`/roles/${id}`,data)  //编辑提交角色
}
export const deleteRole = (id) => {
    return http.delete(`/roles/${id}`)  //删除角色
}
export const deleteRight = (roleId,rightId) => {
    return http.delete(`roles/${roleId}/rights/${rightId}`)  //删除权限
}
export const rightsTree = () => {
    return http.get('/rights/tree')  //权限列表,树形显示
}
export const fpRights = (roleId,rids) => {
    return http.post(`roles/${roleId}/rights`,rids)  //角色授权
}
export const saveRoleInfo = (id,rid) => {
    return http.put(`users/${id}/role`,rid)  //分配用户角色
}
export const cateList = (params) => {
    return http.get('/categories',params)  //商品分类数据列表
}
export const addCate = (data) => {
    return http.post('/categories',data)  //添加商品分类
}
export const getCateId = (id) => {
    return http.get(`/categories/${id}`)  //根据id查询分类 编辑
}
export const editCateInfo = (id,params) => {
    return http.put(`/categories/${id}`,params)  //编辑提交商品分类
}
export const deleteCate = (id) => {
    return http.delete(`/categories/${id}`)  //删除商品分类
}
export const getParams = (id,params) => {
    return http.get(`/categories/${id}/attributes`,params)  //参数列表
}
export const addParams = (id,params) => {
    return http.post(`/categories/${id}/attributes`,params)  //添加参数
}
export const editParams = (id,attrId,params) => {
    return http.get(`/categories/${id}/attributes/${attrId}`,params)  //根据id查询参数 编辑
}
export const editParamsInfo = (id,attrId,params) => {
    return http.put(`/categories/${id}/attributes/${attrId}`,params)  //编辑提交参数
}
export const deleteParams = (id,attrId) => {
    return http.delete(`/categories/${id}/attributes/${attrId}`)  //删除参数
}
export const goodsList = (params) => {
    return http.get('/goods',params)  //商品列表数据
}
export const deleteGoods = (id) => {
    return http.delete(`/goods/${id}`)  //删除商品数据
}
export const addGoods = (data) => {
    return http.post('/goods',data)  //添加商品数据
}
export const orderList = (params) => {
    return http.get('/orders',params)  //订单数据列表
}

export const getReports = () => {
    return http.get('reports/type/1')  //数据图表
}